/*
 * Author : Priyanka & Lin
 * Inspiration : More Unit 
 */
package sg.edu.nus.iss.cerberus.handler;

import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IMethod;

import sg.edu.nus.iss.cerberus.extensionpoint.IAddTestMethodContext;
import sg.edu.nus.iss.cerberus.preferences.Preferences;


public class AddTestMethodContext implements IAddTestMethodContext
{

    /*
     * Final member variables.
     */
    private final ICompilationUnit testClassCompilationUnit;
    private final ICompilationUnit classUnderTestCompilationUnit;
    private final IMethod methodUnderTest;
    private final boolean newTestClassCreated;

    /*
     *  Preferences.
     */
   // private Preferences preferences = null;

    /*
     * This may be modified, if clients replaced test method.
     */
    private IMethod testMethod;

    /**
     * Constructor for AddTestMethodContext.
     * 
     * @param newTestMethod Test method.
     * @param methodUnderTest Method under test.
     */
    public AddTestMethodContext(IMethod testMethod, IMethod methodUnderTest)
    {
        this(testMethod.getCompilationUnit(), testMethod, methodUnderTest.getCompilationUnit(), methodUnderTest, false);
    }

    /**
     * Constructor for AddTestMethodContext.
     * 
     * @param testClassCompilationUnit Test class.
     * @param newTestMethod Test method.
     * @param classUnderTestCompilationUnit Class under test.
     * @param methodUnderTest Method under test.
     */
    public AddTestMethodContext(ICompilationUnit testClassCompilationUnit, IMethod testMethod, ICompilationUnit classUnderTestCompilationUnit, IMethod methodUnderTest)
    {
        this(testClassCompilationUnit, testMethod, classUnderTestCompilationUnit, methodUnderTest, false);
    }

    /**
     * Constructor for AddTestMethodContext.
     * 
     * @param testClassCompilationUnit Test class.
     * @param newTestMethod Test method.
     * @param classUnderTestCompilationUnit Class under test.
     * @param methodUnderTest Method under test.
     * @param newTestClass New test class created?
     */
    public AddTestMethodContext(ICompilationUnit testClassCompilationUnit, IMethod testMethod, ICompilationUnit classUnderTestCompilationUnit, IMethod methodUnderTest, boolean newTestClassCreated)
    {
        this.testClassCompilationUnit = testClassCompilationUnit;
        this.testMethod = testMethod;
        this.classUnderTestCompilationUnit = classUnderTestCompilationUnit;
        this.methodUnderTest = methodUnderTest;
        this.newTestClassCreated = newTestClassCreated;
    }

    /**
     * {@inheritDoc}
     */
    public ICompilationUnit getTestClass()
    {
        return testClassCompilationUnit;
    }

    /**
     * {@inheritDoc}
     */
    public IMethod getTestMethod()
    {
        return testMethod;
    }

    /**
     * {@inheritDoc}
     */
    public void setTestMethod(IMethod testMethod)
    {
        this.testMethod = testMethod;
    }

    /**
     * {@inheritDoc}
     */
    public ICompilationUnit getClassUnderTest()
    {
        return classUnderTestCompilationUnit;
    }

    /**
     * {@inheritDoc}
     */
    public IMethod getMethodUnderTest()
    {
        return methodUnderTest;
    }

    /**
     * {@inheritDoc}
     */
    public boolean isNewTestClassCreated()
    {
        return newTestClassCreated;
    }

    /**
     * {@inheritDoc}
     */
  

    /**
     * {@inheritDoc}
     */
    @Override
    public String toString()
    {
        StringBuilder builder = new StringBuilder();
        builder.append("AddTestMethodContext [");
        builder.append("\n  classUnderTestCompilationUnit=");
        builder.append(classUnderTestCompilationUnit.getElementName());
        builder.append("\n  methodUnderTest=");
        builder.append(methodUnderTest.getElementName());
        builder.append("\n  testMethod=");
        builder.append(testMethod.getElementName());
        builder.append("\n  testClassCompilationUnit=");
        builder.append(testClassCompilationUnit.getElementName());
        builder.append("\n  isNewTestClassCreated=");
        builder.append(isNewTestClassCreated());
        builder.append("\n]");
        return builder.toString();
    }

	@Override
	public Preferences getPreferences() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void setPreferences(Preferences preferences) {
		// TODO Auto-generated method stub
		
	}
}
